package com.itheima.api.treeset.demo04;

import java.util.Scanner;
import java.util.TreeSet;

public class TreeSetDemo04 {

    public static void main(String[] args) {

        TreeSet<Student> treeSet = new TreeSet<>();

        for (int i = 0; i < 3; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入学生姓名");
            String name = scanner.next();
            System.out.println("请输入学生的语文成绩");
            String chineseScore = scanner.next();
            System.out.println("请输入学生的数学成绩");
            String mathScore = scanner.next();
            System.out.println("请输入学生的英语成绩");
            String englishScore = scanner.next();

            Student student = new Student();
            student.setName(name);
            student.setChineseScore(Integer.parseInt(chineseScore));
            student.setMathScore(Integer.parseInt(mathScore));
            student.setEnglishScore(Integer.parseInt(englishScore));

            treeSet.add(student);
        }

        treeSet.forEach( s -> System.out.println(s));
    }
}
